home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9438 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: dynamic_cast costs?
  5. Date: Fri, 01 Mar 1996 16:45:17 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4h79hl$7lc@news.halcyon.com>
  8. NNTP-Posting-Host: blv-pm10-ip9.halcyon.com
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11.     Has anyone profiled the cost of the dynamic_cast<> operation in C++?
  12. Colleaques tell me how expensive it is, but I a have a hard time
  13. believing it's any worst than, say, IUnknown->QueryInterface or other
  14. kind of switch-statement-based function-call.  It's certainly not as
  15. expensive as an exception, is it?
  16.     Doubtless for upcasts to base pointers, it's done at compile-time and
  17. so has no runtime expense, true?
  18.     Also, what exactly happens if your base classes are in one DLL
  19. compiled with RTTI enabled (/GR on MSVC4.0), but some derived classes
  20. are in another DLL w/o RTTI.  If I pass a pDerived into a function as
  21. a pBase pointer, can I downcast to any base class that compiled with
  22. RTTI or am I completely hosed?
  23.     Lastly, in MSVC4, I erroneously tried getting from B1 to B2 without an
  24. intermediate dynamic_cast to D in the following hierarchy:  
  25.  
  26.         class D : public B1, public B2.  
  27.  
  28. It threw an access violation and then a "MS C++ Exception."  I thought
  29. it was just supposed to return NULL if it couldn't make the cast.
  30.     Thoughts?
  31.  
  32.                         --Norm 
  33.  
  34.